import Vue from 'vue'
import VueRouter from 'vue-router'
// import { getToken } from '@/utils/storage'
// 一级路由
import Layout from '@/views/layout'
import Login from '@/views/login'
import Register from '@/views/register'
import NotFound from '@/views/notfound'
import Collect from '@/views/collect'
import MyHouse from '@/views/myhouse'
import CityList from '@/views/citylist'
import Detail from '@/views/detail'
import FangYuan from '@/views/fangyuan'
import Search from '@/views/search'
// 二级路由
import Home from '@/views/home'
import Find from '@/views/find'
import Zixun from '@/views/zixun'
import My from '@/views/my'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children:
  [
    { path: 'home', component: Home },
    { path: 'find', component: Find },
    { path: 'zixun', component: Zixun },
    { path: 'my', component: My }
  ]
  },
  { path: '/login', component: Login },
  { path: '/register', component: Register },
  { path: '/collect', component: Collect },
  { path: '/myhouse', component: MyHouse },
  { path: '/citylist', component: CityList },
  { path: '/detail', component: Detail },
  { path: '/fangyuan', component: FangYuan },
  { path: '/search', component: Search },

  { path: '*', component: NotFound }
]

const router = new VueRouter({
  routes
})

// 前置路由导航守卫
// 白名单页面
// router.router.beforeEach((to, from, next) => {
//   const token = getToken()
// })
export default router
